<?php
namespace Model;
use Think\Model;

class RoleModel extends Model{
    function saveAuth($roleid,$authids){
        $authids_str = implode(',', $authids);
        $authinfo = D('Auth')->select($authids_str);
        $s="";
        foreach ($authinfo as $k=>$v){
            if(!empty($v['auth_c'])&&!empty($v['auth_a'])){
                $s.= $v['auth_c']."-".$v['auth_a'];
            }
        }
        
        $s = rtrim($s,',');
        $sql = "update sw_role set role_auth_ids='$authids_str',role_auth_ac='$s' where role_id='$roleid'";
        return $this -> execute($sql);
    }
}